package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.AnnouncementMapper;
import com.tanhua.model.domain.Announcement;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@DubboService
public class AnnouncementsApiImpl implements AnnouncementsApi{

    @Autowired
    private AnnouncementMapper announcementMapper;
    /**
     * 分页查询所有公告
     * @param page
     * @param pagesize
     * @return
     */
    @Override
    public List<Announcement> announcement(Integer page, Integer pagesize) {
        //构造分页条件，传递参数
        Page<Announcement> pages = new Page<>();
        //调用mapper分页查询所有，无条件
        Page<Announcement> selectPage = announcementMapper.selectPage(pages, null);
        //获取公告集合
        List<Announcement> records = selectPage.getRecords();
        return records;
    }
}
